/**
 * Copyright (c) 2018, wuyy All rights reserved.
 * wuyy 专有/保密源代码,未经许可禁止任何人通过任何渠道使用、修改源代码.
 * QQ:16349023
 * 项目名称 : com.wy2.eclipse.tool.ui
 * @version V1.0
 */
package com.wy2.eclipse.tool.ui.dialog;

import org.eclipse.jface.action.CoolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.StatusLineManager;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.custom.CBanner;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.custom.ViewForm;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.ComboViewer;

/**
 * @author wuyy<16349023@qq.com>
 * @date 2018年1月18日下午9:41:32
 * 
 */
public class TestWindow extends ApplicationWindow {
    private Text textPackage;
    private Text text;

    /**
     * Create the application window,
     */
    public TestWindow() {
        super(null);
        createActions();
        addCoolBar(SWT.FLAT);
        addMenuBar();
        addStatusLine();
    }

    /**
     * Create contents of the application window.
     * @param parent
     */
    @Override
    protected Control createContents(Composite parent) {
        Composite container = new Composite(parent, SWT.NONE);
        container.setLayout(new FillLayout(SWT.HORIZONTAL));
        {
            SashForm sashForm = new SashForm(container, SWT.NONE);
            {
                Group group = new Group(sashForm, SWT.NONE);
                group.setText("配置");
                GridLayout gridLayout = new GridLayout(5, true);
                gridLayout.marginWidth=5;
                
                group.setLayout(gridLayout);
                {
                    Label lblNewLabel = new Label(group, SWT.NONE);
                    lblNewLabel.setText("生成模板");
                    lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
                }
                {
                    ComboViewer comboViewer = new ComboViewer(group, SWT.NONE);
                    Combo combo = comboViewer.getCombo();
                    combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1));
                }
                {
                    Label lblNewLabel_1 = new Label(group, SWT.NONE);
                    lblNewLabel_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
                    lblNewLabel_1.setText("包名");
                }
                {
                    textPackage = new Text(group, SWT.BORDER);
                    textPackage.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1));
                }
                {
                    Label lblNewLabel_2 = new Label(group, SWT.NONE);
                    lblNewLabel_2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
                    lblNewLabel_2.setText("选择要生成的表");
                }
                new Label(group, SWT.NONE);
                new Label(group, SWT.NONE);
                new Label(group, SWT.NONE);
                new Label(group, SWT.NONE);
                {
                    TreeViewer treeViewer = new TreeViewer(group, SWT.BORDER);
                    Tree tree = treeViewer.getTree();
                    tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1));
                }

                
            }
            {
                Group group = new Group(sashForm, SWT.NONE);
                group.setText("操作");
                GridLayout gridLayout = new GridLayout(1, false);
                gridLayout.marginWidth=30;
                group.setLayout(gridLayout);
                
                Button btnTestConnection = new Button(group, SWT.NONE);
                btnTestConnection.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
                btnTestConnection.setText("测试数据连接");
                
                Button btnLoadTables = new Button(group, SWT.NONE);
                btnLoadTables.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
                btnLoadTables.setText("加载表信息");
                
                Button btnGenerate = new Button(group, SWT.NONE);
                btnGenerate.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
                btnGenerate.setText("开始生成");
            }
            sashForm.setWeights(new int[] {8, 3});
            
        }

        return container;
    }

    /**
     * Create the actions.
     */
    private void createActions() {
        // Create the actions
    }

    /**
     * Create the menu manager.
     * @return the menu manager
     */
    @Override
    protected MenuManager createMenuManager() {
        MenuManager menuManager = new MenuManager("menu");
        return menuManager;
    }

    /**
     * Create the coolbar manager.
     * @return the coolbar manager
     */
    @Override
    protected CoolBarManager createCoolBarManager(int style) {
        CoolBarManager coolBarManager = new CoolBarManager(style);
        return coolBarManager;
    }

    /**
     * Create the status line manager.
     * @return the status line manager
     */
    @Override
    protected StatusLineManager createStatusLineManager() {
        StatusLineManager statusLineManager = new StatusLineManager();
        return statusLineManager;
    }

    /**
     * Launch the application.
     * @param args
     */
    public static void main(String args[]) {
        try {
            TestWindow window = new TestWindow();
            window.setBlockOnOpen(true);
            window.open();
            Display.getCurrent().dispose();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * Configure the shell.
     * @param newShell
     */
    @Override
    protected void configureShell(Shell newShell) {
        super.configureShell(newShell);
        newShell.setText("New Application");
    }

    /**
     * Return the initial size of the window.
     */
    @Override
    protected Point getInitialSize() {
        return new Point(800, 556);
    }
}
